package com.yaiys.thread;

import java.util.concurrent.ArrayBlockingQueue;

public class BlockQunceTest {

    public static void main(String[] args) throws InterruptedException {
        ArrayBlockingQueue<String> deque = new ArrayBlockingQueue<String>(10);
        new Thread(() -> {
            for (int i=0;;i++) {
                if (deque.size()<10)
                deque.add(i + "");
            }
        }).start();
        new Thread(() -> {
            for (; ; ) {
                try {
                    Thread.sleep(100);
                    System.out.println(deque.poll());
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }


}
